import Vue from 'vue'
import {
	save,
	saveActivityClue
} from '@/api/axios/clue.js'
Vue.prototype.staticURL = 'https://xiheapp.damaizf.com:29266/xihefile/show/applet';

let types = {
	1: '分享',
	2: '收藏文章',
	3: '文章查看',
	4: '点赞',
	5: '预约挂号查看',
	6: '预约挂号提交',
	7: '互联网医院咨询',
	8: '登录5分钟后',
	9: '填写调查问卷',
	10: '信息登记表填写',
	11: '发布动态',
	12: '打卡签到',
	13: '客服咨询',
	14: '积分商城',
	15: '信息完善',
}

//获取当前时间(年月日时分秒)

Vue.prototype.currentTime = function() {
	let date = new Date()
	let Y = date.getFullYear(); //获取系统的年；
	let M = date.getMonth() + 1; //获取系统月份，由于月份是从0开始计算，所以要加1
	let D = date.getDate(); //获取系统日
	let H = date.getHours(); //获取系统时间
	let m = date.getMinutes() > 10 ? date.getMinutes() : '0' + date.getMinutes(); //分
	let s = date.getSeconds(); //秒
	M = M < 10 ? '0' + M : M
	D = D < 10 ? '0' + D : D
	H = H < 10 ? '0' + H : H
	s = s < 10 ? '0' + s : s
	return Y + '-' + M + '-' + D + ' ' + H + ':' + m + ':' + s
}

Vue.prototype.clue = function(obj, time) {
	let weUserId = uni.getStorageSync('weUserId')
	let customerId = uni.getStorageSync('customerId')
	if (time) {
		setTimeout(() => {
			save({
				weUserId,
				customerId,
				...obj
			})
		}, time)
	} else {
		save({
			weUserId,
			customerId,
			eventStartTime: this.currentTime(),
			eventEndTime: this.currentTime(),
			...obj
		})
	}
}


Vue.prototype.saveActivityClue = function(obj) {
	let customerId = uni.getStorageSync('customerId')
	let customerType = uni.getStorageSync('customerType')
	saveActivityClue({
		customerId: customerId ? customerId : null,
		activityImageId: null,
		customerType: customerType ? customerType : null,
		shareStatus: null,
		location: null,
		deviceInfo: null,
		startDate: null,
		endDate: null,
		...obj
	})
}